Football Statistics¶

Aneesh Krishna Ramesh - 8914620

4 graphs of various chance creators in football. Line Chart, Spider Chart, Bar graph & a Bubble chart¶

In [7]:
import matplotlib as mp
import matplotlib.pyplot as plt
import numpy as np
import plotly.graph_objects as go
import plotly as pl

Line Chart of Bruno fernandes big chance creation every year in the premier league¶

In [131]:
# Bruno fernandes big chance creation every year in the premier league 

years = np.array([2020, 2021, 2022, 2023])
goals = np.array([8, 18, 10, 8])  # Replace with actual key passes data
assists = np.array([7, 12, 6, 8])     # Replace with actual assists data
bigChancesCreated = np.array([3, 20, 15, 32])  # Replace with actual expected assists data

# Create the line chart
plt.figure(figsize=(10, 6))

plt.plot(years, goals, marker='o', label='Goals')
plt.plot(years, assists, marker='o', label='Assists')
plt.plot(years, bigChancesCreated, marker='o', label='Big chances created')

plt.title("Bruno Fernandes's Chance Creation (2020-2023)")
plt.xlabel("Year")
plt.ylabel("Stat Count")
plt.xticks(years)
plt.grid(True)
plt.legend()

plt.show()

Spider Chart of Frenkie De Jong's Spider chart¶

In [9]:
attributes = ["Passing", "Shooting", "Dribbling", "Defending", "Physical"]
values = [88, 82, 85, 65, 75]

fig = go.Figure()

fig.add_trace(go.Scatterpolar(
    r=values,
    theta=attributes,
    fill='toself',
    name='Bruno Fernandes'
))

fig.update_layout(
    polar=dict(
        radialaxis=dict(
            visible=True,
            range=[0, 100]
        )),
    showlegend=True,
    title="Frenkie De Jong's - Midfielder - Football Attributes"
)

fig.show()

"""
References : 

""" 
Out[9]:
'\nReferences : \n\n'

Bar chart of Bruno Fernandes Key Passes per 90 in 2023¶

In [4]:
#Bruno Fernandes Key Passes per 90
matches = ["Wolves", "Spurs", "Nottingham Forest", "Arsenal", "Brighton", "Burnley"]
key_passes = [3, 4, 3, 4, 2, 2]  

plt.figure(figsize=(10, 6))

plt.bar(matches, key_passes, color='blue', alpha=0.5)
plt.title("Key Passes per 90")
plt.xlabel("Football Matches")
plt.ylabel("Key Passes")

plt.xticks(rotation=30, ha="right")  # Rotate x-axis labels for better readability

plt.show()

Bubble Chart comparing 3 chance creators in the world - SpG, Assists & Avg Match Ratings in the year 2019/2020¶

In [3]:
players = ['','J. Maddison', 'B. Fernandes', 'L. Messi']
spg = np.array([0, 2.4, 3.3, 5.6]) 
assists = np.array([0, 5, 12, 9])   
ratings = np.array([0, 7.00, 7.52, 8.52])

fig, ax = plt.subplots(figsize=(5, 5))
scatter = ax.scatter(spg, assists, s=ratings*15, alpha=0.5, c=ratings, cmap='viridis')

for i, player in enumerate(players):
    ax.annotate(player, (spg[i], assists[i]), fontsize=8, ha='center', va='center')

ax.set_xlabel("SpG")
ax.set_ylabel("Assists")
ax.set_title("Football Player Performance")

cbar = plt.colorbar(scatter)
cbar.set_label('Player Rating')

plt.grid(False)
plt.show()
In [11]:
pl.offline.init_notebook_mode()

Data References :

[Transfer Market] (https://www.transfermarkt.us/frenkie-de-jong/profil/spieler/326330) [Who Scored] (https://www.whoscored.com/PlayerComparison) [Who Scored - Bruno fernandes] (https://www.whoscored.com/Players/123761/Show/Bruno-Fernandes) [Who Scored - James Maddison] (https://www.whoscored.com/Players/137015/Show/James-Maddison) [Who Scored - Lionel Messi] (https://www.whoscored.com/Players/11119/Show/Lionel-Messi)